﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Nhom14_HTTTHD_BuyMe.function;

namespace Nhom14_HTTTHD_BuyMe
{
    public partial class special_listing : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string type_w = Request.QueryString["type"];
            int id_w = Convert.ToInt32(Request.QueryString["id"]);
            if (Session["login"] != "1")
                Response.Redirect("login.aspx");
            Label1.Text = Request.QueryString["url"];

/*            if (type_w == "1")
            {
                if (Website.GetAccountID(id_w).ToString() != Session["user"].ToString()) Response.Redirect("Default.aspx");
            }
            else {
                if (Domain.GetAccountID(id_w).ToString() != Session["user"].ToString()) Response.Redirect("Default.aspx");
            }
  */          
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string url = Request.QueryString["url"];
            string id = Request.QueryString["id"];
            string type = Request.QueryString["type"];
            if (url == "" || id == "" || type == "") Response.Redirect("Default.aspx");
            if (Info_Special_Yes.Checked == true)
            {
                using (websitebrokenEntities context = new websitebrokenEntities())
                {
                    //public int payment(int from_account, int to_account, float money, string message)
                    int par1 = Convert.ToInt32(Session["user"]);
                    int par2 = 1;
                    float par3 = 5;
                    string par4 = "Upgrade Premium Listing";
                    int par5 = Convert.ToInt32(id);
                    int par6 = Convert.ToInt32(type);

                    string address = "http://localhost:49744/WebService1.asmx";
                    string function = "UpgradeType";

                    int res = (int)WebserviceInvoker.WSInvoker.CallWebService(address, "WebService1", function, new object[] { par1, par2, par3, par4, par5, par6 });

                    if (res != 0)
                    {
                        //public int UpgradeType(int id_wd, int type)
                       /* int par5 = Convert.ToInt32(id);
                        int par6 = Convert.ToInt32(type);
                        function = "UpgradeType";
                        res = (int)WebserviceInvoker.WSInvoker.CallWebService(address, "WebService1", function, new object[] { par5, par6 });*/

                        //redriect
                    }
                    else {
                        Label2.Text = "Not Enough money!";
                    }
                }
            }
            else { 
                
            }
        }
    }
}